home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / MacPerl 5.1.3 / Mac_Perl_513_src / MacPerl5 / MPFontLDEF.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-22  |  2.0 KB  |  91 lines  |  [TEXT/MPS ]

  1. /*********************************************************************
  2. Project    :    MacPerl                -    Real Perl Application
  3. File        :    MPPreferences.c    -    Handle Preference Settings
  4. Author    :    Matthias Neeracher
  5.  
  6. A lot of this code is borrowed from 7Edit written by
  7. Apple Developer Support UK
  8.  
  9. Language    :    MPW C
  10.  
  11. $Log: MPPreferences.c,v $
  12. Revision 1.2  1994/05/04  02:52:40  neeri
  13. Inline Input.
  14.  
  15. Revision 1.1  1994/02/27  23:01:32  neeri
  16. Initial revision
  17.  
  18. Revision 0.1  1993/12/08  00:00:00  neeri
  19. Separated from MPUtils
  20.  
  21. *********************************************************************/
  22.  
  23. #include <QuickDraw.h>
  24. #include <Gestalt.h>
  25. #include <Script.h>
  26. #include <Fonts.h>
  27. #include <Resources.h>
  28. #include <Lists.h>
  29. #include <LowMem.h>
  30.  
  31. pascal void main(
  32.     short         message, 
  33.     Boolean         selected, 
  34.     Rect *         cellRect,
  35.     Point            cell,
  36.     short            dataOffset,
  37.     short            dataLen,
  38.     ListHandle    list)
  39. {
  40. #if !defined(powerc) && !defined(__powerc)
  41. #pragma unused(dataOffset)
  42. #endif
  43.     short        oldFont;
  44.     short        oldSize;
  45.     short        fontNum;
  46.     short        scriptNum;
  47.     long        result;
  48.     long        sysFont;
  49.     FontInfo    fontInfo;
  50.     Str255    contents;
  51.     
  52.     switch (message) {
  53.     case lInitMsg:
  54.         if (Gestalt(gestaltQuickdrawVersion, &result) || !result) /* B & W QD */
  55.             (*list)->refCon = 0;
  56.         else
  57.             (*list)->refCon = 1;
  58.     case lDrawMsg:
  59.         SetPort((*list)->port);
  60.         oldFont         = (*list)->port->txFont;
  61.         oldSize         = (*list)->port->txSize;
  62.         LGetCell(contents, &dataLen, cell, list);
  63.         GetFNum(contents, &fontNum);
  64.         scriptNum = FontToScript(fontNum);
  65.             
  66.         if (scriptNum == smUninterp)
  67.             scriptNum = smRoman;
  68.         sysFont = GetScriptVariable(scriptNum, smScriptSysFondSize);
  69.         TextFont(sysFont >> 16);
  70.         TextSize(sysFont & 0xFFFF);
  71.         GetFontInfo(&fontInfo);
  72.         MoveTo(cellRect->left+5, cellRect->top + fontInfo.ascent);
  73.         DrawString(contents);
  74.         
  75.         TextFont(oldFont);
  76.         TextSize(oldSize);
  77.         
  78.         if (!selected)
  79.             break;
  80.         
  81.         /* Else fall through to select */
  82.     case lHiliteMsg:
  83.         if ((*list)->refCon)
  84.             LMSetHiliteMode(LMGetHiliteMode() & 0x7F);
  85.         InvertRect(cellRect);
  86.         break;
  87.     default:
  88.         break;
  89.     }
  90. }
  91.